package com.ap.core.domain;

import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;

import javax.persistence.*;

/**
 * User: Ranjit.Singh
 */
@Entity
@Table(name = "T_BASKET_REFERENCE")
@AttributeOverride(name = "id",column = @Column(name = "BASKET_REFERENCE_ID"))
@TypeDef(name = "id", typeClass = Long.class)
@NamedQueries({
        @NamedQuery(name="updateBRNRetrieved", query="UPDATE BasketReference bk SET bk.retrievalTimeStamp = :retrievalTimeStamp WHERE bk.apTransactionId= :apTransactionId")
})
public class BasketReference extends Identifiable<Long>{

    private static final long serialVersionUID = -374982739479238L;

    @Column(name = "BASKET_REFERENCE_NUMBER")
    private String basketReferenceNumber;

       @Column(name = "EXPIRY_TMSTMP")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    private LocalDateTime expiryTimeStamp;

    @Column(name = "retrieval_tmstmp")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    private LocalDateTime retrievalTimeStamp;

    @Column(name = "reconciliation_cycle_id")
    private String  reconciliationCycleId;

    @Column(name = "AP_TXN_ID")
    private String  apTransactionId;

    @Column(name = "reconciliation_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
    private LocalDate reconciliationDate;

    private BasketReference(){}

    public BasketReference(Long id, String basketReferenceNumber, LocalDateTime expiryTimeStamp,
                           String  reconciliationCycleId, LocalDate reconciliationDate) {
        this.id = id;
        this.basketReferenceNumber = basketReferenceNumber;
        this.expiryTimeStamp = expiryTimeStamp;
        this.reconciliationCycleId = reconciliationCycleId;
        this.reconciliationDate = reconciliationDate;
    }



    public String getBasketReferenceNumber() {
        return basketReferenceNumber;
    }

    public LocalDateTime getExpiryTimeStamp() {
        return expiryTimeStamp;
    }


    public LocalDateTime getRetrievalTimeStamp() {
        return retrievalTimeStamp;
    }

    public String getReconciliationCycleId() {
        return reconciliationCycleId;
    }

    public LocalDate getReconciliationDate() {
        return reconciliationDate;
    }

    public void setRetrievalTimeStamp(LocalDateTime retrievalTimeStamp) {
        this.retrievalTimeStamp = retrievalTimeStamp;
    }

    public String getApTransactionId() {
        return apTransactionId;
    }

    public void setApTransactionId(String apTransactionId) {
        this.apTransactionId = apTransactionId;
    }
}